package com.rz.admin.entity;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.rz.core.common.model.PageEntity;

import java.util.List;

@TableName(value = "t_resource")
public class Res extends PageEntity {

    @TableId(type = IdType.AUTO)
    private Integer id;
    private String code;
    private String name;
    private String resPath;
    private Integer parentId;
    private Integer type;
    private String icon;
    private Integer sortBy;
    @TableField(exist = false)
    private String resTypeName;
    private Integer level;
    private Integer leaf;

    @TableField(exist = false)
    private List<Res> children;
    @TableField(exist = false)
    private String parentName;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getResPath() {
        return resPath;
    }

    public void setResPath(String resPath) {
        this.resPath = resPath;
    }

    public Integer getParentId() {
        return parentId;
    }

    public void setParentId(Integer parentId) {
        this.parentId = parentId;
    }

    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    public List<Res> getChildren() {
        return children;
    }

    public void setChildren(List<Res> children) {
        this.children = children;
    }

    public String getIcon() {
        return icon;
    }

    public void setIcon(String icon) {
        this.icon = icon;
    }

    public Integer getSortBy() {
        return sortBy;
    }

    public void setSortBy(Integer sortBy) {
        this.sortBy = sortBy;
    }

    public Integer getKey() {
        return this.id;
    }

    public String getTitle() {
        return this.name;
    }

    public String getResTypeName() {
        switch (this.type){
            case 0:
                resTypeName = "目录";
                break;
            case 1:
                resTypeName = "模块";
                break;
            case 2:
                resTypeName = "菜单";
                break;
            case 3:
                resTypeName = "按钮";
                break;
        }
        return resTypeName;
    }

    public Integer getLevel() {
        return level;
    }

    public void setLevel(Integer level) {
        this.level = level;
    }

    public String getParentName() {
        return parentName;
    }

    public void setParentName(String parentName) {
        this.parentName = parentName;
    }

    public Integer getLeaf() {
        return leaf;
    }

    public void setLeaf(Integer leaf) {
        this.leaf = leaf;
    }
}
